<?php
/* 
* @Author: Administrator
* @Date:   2014-07-27 07:58:19
* @Last Modified by:   Administrator
* @Last Modified time: 2014-07-27 08:11:15
*/

/**
* 简历职位表视图模型
*/
class ResumePosViewModel  extends ViewModel
{
	public $table= 'people_resume2';

	public $view = array(
		'relation_resume2_pos' => array(
			'type'	=>	INNER_JOIN,
			'on'	=>	'people_resume2.resume1_reid=relation_resume2_pos.re_reid'
			),
		'positioncate' => array(
			'type'	=>	INNER_JOIN,
			'on'	=>	'relation_resume2_pos.re_posid=positioncate.posid'
			),
		);


	public function get_posname($reid)
	{
		$res = $this->where(array('resume1_reid'=>$reid))->field('posname')->all();
		$posname = '';
		foreach ($res as $v) {
			$posname .= $v['posname'] . '/';
		}
		return rtrim($posname,'/');
	}
	public function get_posname_arr($reid)
	{
		$res = $this->where(array('resume1_reid'=>$reid))->field('posname')->all();
		// p($res);
		$k = rand(0,count($res)-1);
		return $res[$k]['posname'];
	}

	public function get_pos_index($data)
	{
		foreach ($data as $key => $value) {
			$data[$key]['posname'] = $this->get_posname_arr($value['reid']);
		}
		// p($data);
		return $data;
	}
}
?>
